from tornado import web, ioloop
import os

class IndexHandler(web.RequestHandler):
    def get(self):
        self.finish("Hello Tornado!")

settings = {
    'static_path': './static/',
    'static_url_prefix': '/img/'
}

if __name__ == "__main__":
    static_url = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static')
    app = web.Application([
        web.URLSpec('/', IndexHandler, name='index'),
        ('/img/(.*)', web.StaticFileHandler, {'path': static_url}), # 方法二
    ],
    debug=True,
    # static_path='./static/',
    # static_url_prefix='/img/')
    # **settings # 方法一
    )
    app.listen(8080)
    ioloop.IOLoop.current().start()